package test;

import common.Utils;
import org.junit.jupiter.api.Assertions;
import org.openqa.selenium.By;

public class ListPage extends Utils {

    public static String url = "http://8.137.19.140:9090/blog_list.html";

    public ListPage() {
        super(url);
    }

    /**
     * 博客列表页--三个模块（菜单模块、用户信息模块、博客列表模块）
     */
    // 检查博客列表模块是否正确
    public void checkBlogList(){
        // 检查博客标题
        String titleText = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(3) > div.title")).getText();
        // 检查博客时间
        String timeText = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(3) > div.date")).getText();
        // 检查博客内容
        String contentText = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(3) > div.desc")).getText();
        // 检查查看全文按钮
        String actualText = driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(3) > a")).getText();

        String expectText = "查看全文>>";
//        String expectText = "全文";
        // 校验查看全文按钮
        Assertions.assertEquals(expectText, actualText);

        // 校验标题、博客内容、时间不能为空
        Assertions.assertNotNull(titleText);
        Assertions.assertNotNull(timeText);
        Assertions.assertNotNull(contentText);

        driver.findElement(By.cssSelector("body > div.container > div.right > div:nth-child(3) > a")).click();
        // 跳转到博客详情页 --- 一定是有效的
        DetailUrl = driver.getCurrentUrl();
    }
}
